package servlet;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import service.LogicService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;

@WebServlet(name = "UserSelectAllServlet",value = "/UserSelectAllServlet")
public class UserSelectAllServlet extends HttpServlet {
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException{
        this.doPost(req,resp);
    }

    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException{
        resp.setContentType("text/html; charset=utf-8");
        PrintWriter out=resp.getWriter();
        LogicService logicService=new LogicService();
        JSONObject js=null;
        String a=req.getParameter("teacher");
        String b=req.getParameter("classes");
        String c=req.getParameter("startDate");
        String d=req.getParameter("endDate");
        Integer se=Integer.parseInt(req.getParameter("sel"));
        int ee=Integer.parseInt(req.getParameter("dang"));

        try {
            js=logicService.selectAll(b,a,c,d,se,ee,8);
        } catch (SQLException e) {
            e.printStackTrace();
        }

        out.print(js.toJSONString());
    }


}
